<template>
  <div>
    <!-- 无图的 -->

     <div v-if="item.cover.type===0" class="article-item van-hairline--bottom"
     @click="$router.push('/article?id='+item.art_id)" >
     <!-- 点击跳转 -->
    <p class="title van-multi-ellipsis--l2">{{item.title}}</p>
    <div class="info">
      <span>{{item.aut_name}}</span>
      <span>{{item.comm_count}}评论</span>
      <span>1天前</span>
      <van-icon name="close"></van-icon>
    </div>
  </div>
  <!-- 三图的 -->
    <div v-if="item.cover.type===3" class="article-item van-hairline--bottom"
    @click="$router.push('/article?id='+item.art_id)" >
    <p class="title van-multi-ellipsis--l2">{{item.title}}</p>
    <img class="img" :src="item.cover.images[0]" alt="">
    <img class="img" :src="item.cover.images[1]" alt="">
    <img class="img" :src="item.cover.images[2]" alt="">
    <div class="info">
      <span>{{item.aut_name}}</span>
      <span>{{item.comm_count}}评论</span>
      <span>1天前</span>
      <van-icon name="close"></van-icon>
    </div>
  </div>
  <!-- 单图 -->
  <div v-if="item.cover.type===1" class="article-item van-hairline--bottom"
  @click="$router.push('/article?id='+item.art_id)">
    <p class="title van-multi-ellipsis--l2 w66">{{item.title}}</p>
    <img class="img" :src="item.cover.images[0]" alt="">
    <div class="info">
      <span>{{item.aut_name}}</span>
      <span>{{item.comm_count}}评论</span>
      <span>1天前</span>
      <van-icon name="close"></van-icon>
    </div>
  </div>
  </div>
</template>

<script>

export default {
  name: 'ArticleItem',
  props: {
    item: {
      type: Object,
      required: true
    }
  }
}
</script>
<style scoped lang="less">
.article-item {
  padding: 15px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  .title {
    width: 100%;
    margin: 0;
    line-height: 22px;
    font-size: 16px;
    color: #333;
    margin-bottom: 8px;
    max-height: 44px;
    &.w66 {
      width: 66%;
    }
  }
  .img {
    width: 112px;
    height: 74px;
    border-radius: 4px;
    margin-bottom: 8px;
  }
  .info {
    width: 100%;
    color: #A5A6AB;
    font-size: 12px;
    position: relative;
    span {
      margin-right: 12px;
    }
    .van-icon {
      float: right;
      font-size: 14px;
    }
  }
}
</style>
